﻿using Abp.AutoMapper;
using Paas.Core.Common.Entities;
using Paas.Core.Const.Enums.Common;
using Basefr.App.Dtos;
using Basefr.Runtime.Extensions;

namespace Paas.App.Interface.Common.Dtos
{
    [AutoMap(typeof(File))]
    public class FileDto : DtoBase
    {
        public EnumFileType Type { get; set; }
        public string TypeStr => Type.Description();

        public string Name { get; set; }

        public string MimeType { get; set; }

        public string Code { get; set; }

        public long Size { get; set; }
        public string SizeStr => Size > 1024 * 1024
            ? (Size / (float)(1024 * 1024)).ToString("N2") + " MB"
            : (Size / (float)1024).ToString("N2") + " KB";


        public bool IsSys { get; set; }

        public long? UploaderId { get; set; }
        public string UploaderName { get; set; }

        public string PhysicalName { get; set; }


        public string DownloadUrl => $"/Download/File?id={Id}&code={Code}";

    }
}

